package com.ln.cmsln.controller.wei;

import com.ln.cmsln.pojo.entity.wei.Consulting;
import com.ln.cmsln.service.wei.ConsultingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 魏存文
 * @since 2022-03-31
 */

@Api(tags = "动态资讯")
@RestController
@RequestMapping("/api/consulting")
@CrossOrigin

public class ConsultingController {
    @Resource
    private ConsultingService consultingService;

    @ApiOperation("动态资讯列表")
    @GetMapping("/list")
    public Object list(){
        List<Consulting> list = consultingService.list();
        HashMap<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("count", 0);
        map.put("data", list);
        return map;
    }

    @ApiOperation("新增动态资讯")
    @PostMapping("/save")
    public boolean save(
            @ApiParam(value = "动态详情数据",required = true)
            Consulting consulting
    ){
        return consultingService.save(consulting);
    }

    @ApiOperation("删除动态资讯")
    @PostMapping("/delete")
    public boolean delete(Long id){
        return consultingService.removeById(id);
    }

}

